var supplyData = {
	data: {
		todayLinksData: [],
		prevSupplyInfo: []
	},
	mounted: function() {
		this.getSupplyData();
	},
	methods: {
		getSupplyData: function() {
			var T = this;
			mui.ajax({
				url: "https://wiki.guildwars2.com/wiki/Pact_Supply_Network_Agent",
				type: "GET",
				dataType: "html",
				success: function(html) {
					var table = $(html).find(".npc.table")[0];

					//表头
					var titles = [];

					//任务名称
					var npcTDs = $(table).find('tr').eq(1).find("td");
					var npcs = [];

					//位置名称
					var today = $(table).find('tr[title="Today\'s locations"]');
					var todayNames = [];

					//地理坐标
					var todayLinks = $(table).find('tr[title="Today\'s chat links"]');
					var todayLinksData = [];

					npcTDs.each(function(index) {
						npcs.push($(this).find('a').text());
					});

					$(table).find('th').each(function() {
						titles.push($(this).text());
					});

					$(today).find('td').each(function() {
						todayNames.push($(this).text());
					});

					$(todayLinks).find('td').each(function() {
						var span = $(this).find("span.gamelink");
						todayLinksData.push({
							type: 'map',
							id: $(span).attr('data-id')
						});
					});

					todayLinksData.forEach(function(obj, index) {
						obj.pointName = todayNames[index];
						obj.npcName = npcs[index];
						obj.code = encodeChatLink('map', obj.id);
					});

					//去除第一个
					todayLinksData.splice(0, 1);
					var nowHash = md5(JSON.stringify(todayLinksData));
					if(!plus.storage.getItem("prevSupplyInfo")) {
						plus.storage.setItem("prevSupplyInfo", "[]");
					}
					
					console.log(md5(plus.storage.getItem("nowSupplyInfo")));
					console.log(nowHash);
					if(md5(plus.storage.getItem("nowSupplyInfo")) == nowHash) {
						//不做操作
						plus.storage.setItem("nowSupplyInfo", JSON.stringify(todayLinksData));
					} else {
						plus.storage.setItem("prevSupplyInfo", plus.storage.getItem("nowSupplyInfo"));
						plus.storage.setItem("nowSupplyInfo", JSON.stringify(todayLinksData));
					}
					T.todayLinksData = JSON.parse(plus.storage.getItem("nowSupplyInfo"));
					T.prevSupplyInfo = JSON.parse(plus.storage.getItem("prevSupplyInfo"));
				}
			});
		}
	}
};